import { BasicColumn } from '/@/components/Table';
import { FormSchema } from '/@/components/Table';

export const columns: BasicColumn[] = [
  {
    title: '任务名称',
    dataIndex: 'sourceName',
    width: 300,
  },
  {
    title: '任务类型',
    dataIndex: 'typeCode',
    width: 280,
  },
  {
    title: 'ID',
    dataIndex: 'id',
  },
  {
    title: '状态',
    dataIndex: 'isUsing',
    width: 180,
    slots: { customRender: 'isUsing' },
  },
  {
    title: 'cron表达式',
    dataIndex: 'cronExpression',
    width: 180,
  },
  {
    title: '下次执行时间',
    dataIndex: 'nextRunTime',
    width: 180,
  },
];

export const searchFormSchema: FormSchema[] = [
  {
    field: 'sourceName',
    label: '任务名称',
    component: 'Input',
    colProps: { span: 6 },
  },
  {
    field: 'id',
    label: '任务ID',
    component: 'Input',
    colProps: { span: 6 },
  },
  {
    field: 'isUsing',
    label: '任务状态',
    component: 'Select',
    colProps: { span: 6 },
    componentProps: {
      options: [
        {
          label: '启用',
          value: 'Y',
        },
        {
          label: '禁用',
          value: 'N',
        },
      ],
    },
  },
];

export const formSchema: FormSchema[] = [
  {
    field: 'typeCode',
    label: '任务类型',
    component: 'Input',
    required: true,
    componentProps: {
      disabled: true,
    },
  },
  {
    field: 'id',
    label: 'ID',
    required: true,
    component: 'Input',
    componentProps: {
      disabled: true,
    },
  },
  {
    field: 'sourceName',
    label: '任务名称',
    required: true,
    component: 'Input',
    componentProps: {
      disabled: true,
    },
  },
  {
    field: 'isUsing',
    label: '状态',
    required: true,
    component: 'Switch',
  },
  {
    label: 'cron表达式',
    field: 'cronExpression',
    required: true,
    component: 'Input',
  },
];
